<?php

namespace IDock\Insurance\DAJIA\Response;

use IDock\Http\Response;
use IDock\Printer\ValidateCarCodePrinter;

class ValidateCarResponse extends AllDAJIAResponse
{

    public function printerInit(): Response
    {
        $this->printer = new ValidateCarCodePrinter();

        $data = $this->get('body',[]);

        if(!in_array($data['status'],['0000','0001'])){
            $this->setError($data['message']);
            throw new \Exception($data['message']);
        }

        $this->printer->code = $data['result']['validateCode'] ?? '';

        return $this;
    }
}
